package com.qingcloud.base.api.remote.datafusion;

import com.qingcloud.base.api.remote.datafusion.factory.DatafusionApiFallbackFactory;
import com.qingcloud.base.constant.AppNameConstant;
import com.qingcloud.base.pojo.ApiResult;
import com.qingcloud.base.remote.datafusion.SourceInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(contextId = "datafusionApi", path = "manager", value = AppNameConstant.APP_DATA_FUSION, fallbackFactory = DatafusionApiFallbackFactory.class)
public interface DatafusionApi {

    /**
     * 查询实例源码信息
     */
    @GetMapping("jobapi/instance/source/{instanceId}")
    ApiResult findsourceByInstanceId(@PathVariable("instanceId") Integer instanceId);

    /**
     * 查询需要监听的topic
     */
    @PostMapping("jobapi/instance/findTopicsBytype")
    ApiResult findTopics(@RequestBody List<Integer> types);

    /**
     * 获取实例基本信息
     */
    @GetMapping("jobapi/instance/findInstanceById/{instanceId}")
    ApiResult findInstanceById(@PathVariable("instanceId") Integer instanceId);

    /**
     * 根据源码Id查询源码信息
     */
    @GetMapping("jobapi/instance/findSourceById/{id}")
    ApiResult findSourceById(@PathVariable("id") Integer id);

    /**
     * 查询实例的 数据来源关联的产品Id
     *
     * @return productId
     */
    @GetMapping("jobapi/instance/findProductIdByInstanceId/{instanceId}")
    ApiResult findProductIdByInstanceId(@PathVariable("instanceId") Integer instanceId);

    /**
     * 批量查询源码
     *
     * @param sourceIds
     * @return
     */
    @GetMapping("commonSource/findSourcesById/")
    ApiResult findSourcesById(@RequestParam(name = "sourceIds") List<Integer> sourceIds);

    /**
     * 保存或修改公共源码信息
     *
     * @param sources
     * @return
     */
    @GetMapping("commonSource/saveSource")
    ApiResult saveSource(@RequestBody SourceInfo sources);

    /**
     * 根据id删除源码信息
     *
     * @param sourceIds
     * @return
     */
    @GetMapping("commonSource/deleteBySourceId")
    ApiResult deleteBySourceId(@RequestParam(name = "sourceId") List<Integer> sourceIds);

    /**
     * 分页查询解码器组件
     *
     * @param name     名称模糊搜索
     * @param page     页码，从1开始
     * @param pageSize 每页数量
     * @return
     */
    @GetMapping("globalComponent/components/decoder")
    ApiResult findDecoderComponent(@RequestParam(value = "name", required = false) String name,
                                   @RequestParam("page") int page,
                                   @RequestParam("pageSize") int pageSize);


    /**
     * 客户端API访问权限
     * @param clientId
     * @return
     */
    @GetMapping("/getCustomerApiByClientId/{clientId}")
    ApiResult getCustomerApiByClientId(@PathVariable("clientId") String clientId);

}
